package Interfaces;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

@SuppressWarnings("serial")
class CR_manage extends JOptionPane
{
  public static String[] showInputDialog(final String message, final String Area1, final String Area2)
  {
    String[] data = new String[2];
    
    class GetData extends JDialog implements ActionListener
    {
      AreaTesto condition = new AreaTesto();
	  AreaTesto reaction = new AreaTesto();
      JButton btnOK = new JButton("   OK   ");
      JButton btnCancel = new JButton("Cancel");
      String[] CR = null;
      public GetData()
      {
    	condition.crea(Area1, 1);
  		reaction.crea(Area2, 1);
  		
        setModal(true);
        setLocation(200, 200);
        getContentPane().setLayout(new BorderLayout());
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        setMinimumSize(new Dimension(400,200));
        getContentPane().add(new JLabel(message),BorderLayout.NORTH);
        JPanel aux = new JPanel();
        aux.setLayout(new GridLayout(1,2));
        aux.add(condition.get());
        aux.add(reaction.get());
        getContentPane().add(aux,BorderLayout.CENTER);
        JPanel jp = new JPanel();
        btnOK.addActionListener(this);
        btnCancel.addActionListener(this);
        jp.add(btnOK);
        jp.add(btnCancel);
        getContentPane().add(jp,BorderLayout.SOUTH);
        setVisible(true);
      }
      
      public void actionPerformed(ActionEvent ae)
      {
        if(ae.getSource() == btnOK) 
    	{
        	CR = new String[2];
        	CR[0] = condition.getText();
        	CR[1] = reaction.getText();
    	}
        dispose();
      }
      public String[] getData(){return CR;}
    }
    data = new GetData().getData();
    return data;
  }
}